home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 January: Mac OS SDK / Dev.CD Jan 98 SDK2.toast / Development Kits (Disc 2) / QuickDraw GX / Programming Stuff / Sample Code / Printing Samples / Printer Drivers… / ImageWriter--DTP renamer / OldApp.c < prev    next >
Encoding:
Text File  |  1996-06-15  |  18.2 KB  |  660 lines  |  [TEXT/MPS ]

  1. /*
  2.     copyright © 1992-1996 Apple Computer Inc.  All rights reserved.
  3.     
  4.     OldApp.c
  5.     This file implements old application message overrides for the specific driver.
  6.     
  7.     Included in this file is the old PrintRecord emulation.  Note that the ImageWriter
  8.     PrintRecord is a wonder of misdirection and special cases.  You'll have fun
  9.     figuring out the code - so unless you really want to exactly emulate the ImageWriter
  10.     pages, you shouldn't spend too much time looking at this code.
  11.     
  12.     Modification history
  13.     7/23/92            TED            New file today
  14.     12/20/93        dmh            Sync'd with the shipping 1.0b3 GX driver.
  15.      6/23/94        dmh            Added overrides for renaming DTPs.
  16.      8/26/94        dmh            Sync'd with the shipping 1.0.1 GX driver.
  17.      6/14/96        cn            Updated to support Universal Interfaces 2.1.
  18.  
  19. */
  20.  
  21. // Include the standard Mac header files 
  22. #include <Errors.h>
  23. #include <ToolUtils.h>
  24. #include <StdIO.h>
  25. #include <StdLib.h>
  26. #include <String.h>
  27. #include <Strings.h>
  28. #include <Resources.h>
  29. #include <ToolUtils.h>
  30. #include <OSUtils.h>
  31. #include <Files.h>
  32. #include <Types.h>
  33. #include <Packages.h>
  34. #include <Memory.h>
  35. #include <Serial.h>
  36. #include <Devices.h>
  37. #include <Fonts.h>
  38. #include <Printing.h>
  39. #include <Script.h>
  40. #include <Events.h>
  41. #include <Dialogs.h>
  42. #include <FixMath.h>
  43. #include <Lists.h>
  44. #include <AppleTalk.h>
  45. #include <Menus.h>
  46. #include <Events.h>
  47. #include <Balloons.h>
  48. #include <Folders.h>
  49. #include <SCSI.h>
  50.  
  51. // Include the new QuickDraw GX graphics header files 
  52. #include <GXGraphics.h>
  53. #include <GraphicsLibraries.h>
  54. #include <GXMath.h>
  55. #include <QDLibrary.h>
  56. #include <FontLibrary.h>
  57. #include <GXLayout.h>
  58.  
  59. // Include the required Printing Manager header files 
  60. #include <GXPrinting.h>
  61. #include <GXPrinterDrivers.h>
  62. #include <Collections.h>
  63. #include <GXMessages.h>
  64. #include <PrintingLibraries.h>
  65.  
  66. #include <GXExceptions.h>
  67.  
  68. #include "CommonDefines.h"            // things common to .r and .h files
  69.  
  70. /* ----------------------------------------------------------------------------    */
  71. /* INTERNAL TYPEDEFS AND STRUCTURES                                                */
  72. /* ----------------------------------------------------------------------------    */
  73. // ImageWriter wDev values
  74. #define kBest            0x01
  75. #define kPortrait        0x02
  76. #define kTallAdjusted    0x04
  77. #define k50Percent        0x08
  78. #define kNoGaps            0x10
  79. #define kSetResCalled    0x20
  80.  
  81. // some ImageWriter constants
  82. #define kGapSize        60        // gap at top of page in 120ths of an inch
  83. #define kSmallPlaten    16        // platen width in half inches for small IW
  84. #define kBigPlaten        27        // platen width in half inches for the 15" IW
  85.  
  86. /* ----------------------------------------------------------------------------    */
  87. /* FORWARD DECLARES                                                                */
  88. /* ----------------------------------------------------------------------------    */
  89. OSErr SD_ConvertPrintRecordTo(THPrint hoPrint);
  90. OSErr SD_ConvertPrintRecordFrom(gxUniversalPrintRecordHdl huPrint);
  91.  
  92.  
  93. /* ----------------------------------------------------------------------------    */
  94. /* INTERNAL ROUTINES                                                            */
  95. /* ----------------------------------------------------------------------------    */
  96. OSErr    UpdatePrintRecord(THPrint hPrint)
  97. {
  98.     OSErr                        anErr;
  99.     gxUniversalPrintRecordHdl     huPrint = (gxUniversalPrintRecordHdl) hPrint;
  100.     gxUniversalPrintRecordPtr     puPrint;
  101.     short                        devVRes, devHRes, appVRes, appHRes;
  102.     short                        cPlaten;
  103.     
  104.     // convert to universal format
  105.     anErr = SD_ConvertPrintRecordTo(hPrint);
  106.     if (anErr == noErr)
  107.         {
  108.         // determine application & device resolutions, based upon quality mode, tall adjusted
  109.         // setting, and if the app called SetRsl:
  110.         //    draft - 80(h)*72(v)
  111.         //    faster - 80(h)*72(v)
  112.         //    best - 160(h)*144(v)
  113.         //
  114.         //    draft (tall adjusted) - 72*72
  115.         //    faster (tall adjusted) - 72*72
  116.         //    best (tall adjusted) - 144*144
  117.         
  118.         puPrint = *huPrint;
  119.         if (puPrint->options & gxPreciseBitmap)
  120.             switch(puPrint->qualityMode)
  121.                 {
  122.                 case gxDraftQuality:
  123.                 case gxFasterQuality:
  124.                     devVRes = devHRes = 72;
  125.                     appVRes = appHRes = 72;
  126.                     break;
  127.                     
  128.                 case gxBestQuality:
  129.                     devVRes = devHRes = 144;
  130.                     appVRes = appHRes = 72;
  131.                     break;
  132.                 }
  133.         else
  134.             switch(puPrint->qualityMode)
  135.                 {
  136.                 case gxDraftQuality:
  137.                 case gxFasterQuality:
  138.                     appVRes = devVRes = 72;
  139.                     appHRes = devHRes = 80;
  140.                     break;
  141.                     
  142.                 case gxBestQuality:
  143.                     devVRes = 144;
  144.                     devHRes = 160;
  145.                     appVRes = 72;
  146.                     appHRes = 80;
  147.                     break;
  148.                 }
  149.             
  150.         // SetRsl was called?  Use the resolution specified by the application
  151.         if (puPrint->appVRes != 72)
  152.             {
  153.             appVRes = devVRes = puPrint->appVRes;
  154.             appHRes = devHRes = puPrint->appHRes;
  155.             }
  156.             
  157.         // finally, store the app & device resolutions
  158.         puPrint->devVRes = devVRes;
  159.         puPrint->devHRes = devHRes;
  160.         puPrint->appVRes = appVRes;
  161.         puPrint->appHRes = appHRes;
  162.         
  163.         // here we do page size calculations
  164.         // Please note that this code is confusing - it's purpose is to emulate
  165.         // the existing ImageWriter driver's page size.  Most drivers would not
  166.         // do this - the existing in the system probably is good enough.
  167.         {
  168.         long        pageGap;                // gap at top of page
  169.         long        dvPaper, dhPaper;        // paper size at device res
  170.         long        dvPage, dhPage;            // page size at device res
  171.         long        scanLines, scanBits;    // # of scan lines or bits on page
  172.         long        maxH;                    // maximum width
  173.         long        hOff, vOff;                // margins (horiz & vert) to get paper rect from page rect
  174.         
  175.         // gap at the top of the page in pixels
  176.         pageGap = (kGapSize * appVRes) / 120;
  177.         if (puPrint->options & gxBiggerPages)
  178.             pageGap = 0;
  179.             
  180.         // figure out paper size in application space pixels
  181.         dvPaper = (puPrint->pageV * appVRes) / 120;
  182.         dhPaper = (puPrint->pageH * appHRes) / 120;
  183.                 
  184.         // vertically, align to the head height of 8 pixels
  185.         scanLines = ((dvPaper - pageGap) >> 3) << 3;
  186.         
  187.         // horizontally, allow the biggest width we can handle
  188.         cPlaten = kSmallPlaten;
  189.         if (puPrint->pageH > (9*120) )
  190.             cPlaten = kBigPlaten;
  191.             
  192.         maxH = (cPlaten * appHRes) >> 1;
  193.         if (maxH > dhPaper)
  194.             maxH = dhPaper;
  195.         scanBits = (maxH >> 4) << 4;
  196.         
  197.         if (puPrint->orientation == gxPortraitOrientation)
  198.             {
  199.             // portrait
  200.             
  201.             dhPage = scanBits;
  202.             dvPage = scanLines;
  203.             
  204.             hOff = (dhPage - dhPaper) >> 1;
  205.             vOff = -pageGap;
  206.             }
  207.         else
  208.             {
  209.             // landscape
  210.             
  211.             dhPage = scanLines;
  212.             dvPage = scanBits;
  213.             
  214.             // reverse the paper definition as well
  215.             {
  216.             long iTemp = dhPaper;
  217.             dhPaper = dvPaper;
  218.             dvPaper = iTemp;
  219.             }
  220.             
  221.             hOff = -pageGap;
  222.             vOff = (dvPage - dvPaper) >> 1;
  223.             }
  224.             
  225.         // 50% reduction?  scale everything by 2X
  226.         if (puPrint->options & gxUserFlag0)
  227.             {
  228.             dhPage <<= 1;
  229.             dvPage <<= 1;
  230.             dhPaper <<= 1;
  231.             dvPaper <<= 1;
  232.             hOff <<= 1;
  233.             vOff <<= 1;
  234.             }
  235.             
  236.         // set the page and paper in app space
  237.         puPrint->appPage.left         = puPrint->appPage.top = 0;
  238.         puPrint->appPage.right         = dhPage;
  239.         puPrint->appPage.bottom     = dvPage;
  240.         
  241.         puPrint->appPaper.left         = hOff;
  242.         puPrint->appPaper.top         = vOff;
  243.         puPrint->appPaper.right     = dhPaper + hOff;
  244.         puPrint->appPaper.bottom     = dvPaper + vOff;
  245.                 
  246.         // from page, scale up to device space (in case some weenie decides to look at that)
  247.         puPrint->devPage.left         = puPrint->devPage.top = 0;
  248.         puPrint->devPage.right         = dhPage * devHRes / appHRes;
  249.         puPrint->devPage.bottom     = dvPage * devVRes / appVRes;
  250.         }
  251.         
  252.         // convert back to non-universal format
  253.         anErr = SD_ConvertPrintRecordFrom((gxUniversalPrintRecordHdl) hPrint);
  254.         }
  255.         
  256.     return(anErr);
  257.     
  258. } // UpdatePrintRecord
  259.  
  260. //<FF>
  261. /* ----------------------------------------------------------------------------    */
  262. /* MESSAGE OVERRIDES                                                            */
  263. /* ----------------------------------------------------------------------------    */
  264. OSErr SD_ConvertPrintRecordTo(THPrint hoPrint)
  265. /*
  266.     This call takes a print record in old style (driver specific) format, and
  267.     converts it to the format of "gxUniversalPrintRecordHdl"
  268. */
  269. {
  270.     TPPrint                        poPrint;            // pointer to old style print record
  271.     gxUniversalPrintRecordHdl    huPrint = (gxUniversalPrintRecordHdl) hoPrint;    // handle to universal print record
  272.     gxUniversalPrintRecordPtr    puPrint;            // pointer to universal print record
  273.     short                        qualityMode;        // cached quality mode
  274.     short                        wDev;                // cached wDev
  275.     
  276.     // cache pointers for size and speed
  277.     puPrint = *huPrint;
  278.     poPrint = *hoPrint;
  279.     wDev = poPrint->prStl.wDev;
  280.     
  281.     // determine quality mode
  282.     if (poPrint->prJob.bJDocLoop == 0)
  283.         qualityMode = gxDraftQuality;
  284.     else
  285.         {
  286.         if (wDev & kBest)
  287.             qualityMode = gxBestQuality;
  288.         else
  289.             qualityMode = gxFasterQuality;
  290.         }
  291.         
  292.     // universal feed is the inverse of our feed
  293.     puPrint->feed            =    1-(poPrint->prStl.feed);
  294.     
  295.     // wDev 0x02 means portrait, else landscape
  296.     if (wDev & kPortrait) 
  297.         puPrint->orientation    =    gxPortraitOrientation;
  298.     else
  299.         {
  300.         puPrint->orientation    =    gxLandscapeOrientation;
  301.         
  302.         // landscape disabled draft, forces tall adjusted
  303.         if (qualityMode == gxDraftQuality)
  304.             qualityMode = gxFasterQuality;
  305.         wDev |= kTallAdjusted;
  306.         }
  307.         
  308.     // copies are in iCopies field (wow.)
  309.     puPrint->actualCopies        =    poPrint->prJob.iCopies;
  310.     
  311.     // store our flags
  312.     puPrint->options = 0;
  313.     
  314.     // tall adjusted
  315.     if (wDev & kTallAdjusted) 
  316.         puPrint->options |= gxPreciseBitmap;
  317.         
  318.     // 50% reduction
  319.     if (wDev & k50Percent) 
  320.         {
  321.         puPrint->options |= gxUserFlag0;
  322.         puPrint->reduction = 50;
  323.         
  324.         // for 50% reduction, we always return faster to the application
  325.         qualityMode = gxFasterQuality;
  326.         }
  327.     else
  328.         puPrint->reduction = 100;
  329.         
  330.     // no gaps
  331.     if (wDev & kNoGaps) 
  332.         puPrint->options |= gxBiggerPages;
  333.     
  334.     // finally, store quality mode    
  335.     puPrint->qualityMode = qualityMode;
  336.     
  337.     // and we can't have any errors - because this code is too godlike.
  338.     return(noErr);
  339.     
  340. } // SD_ConvertPrintRecordTo
  341.  
  342. //<FF>
  343. /* ----------------------------------------------------------------------------    */
  344. OSErr SD_ConvertPrintRecordFrom(gxUniversalPrintRecordHdl huPrint)
  345. /*
  346.     This call takes a print record in universal format and converts it
  347.     to old style (driver specific) format.
  348.     
  349.     Note: for the ImageWriter, I'm filling in way more things than theoretically
  350.     I need to.  However, since the ImageWriter is one of the oldest print drivers,
  351.     there is much more of a chance that someone assumes something about one or
  352.     more of the fields.
  353. */
  354. {
  355.     gxUniversalPrintRecordPtr    puPrint;            // pointer to universal print record
  356.     THPrint                        hoPrint = (THPrint) huPrint;    // handle to old style print record
  357.     TPPrint                        poPrint;            // pointer to old style print record
  358.     short                        options;            // cached universal options
  359.     short                        qualityMode;        // cached universal quality mode
  360.     short                        actualCopies;        // cached universal copies
  361.     
  362.     // cache pointers for size and speed
  363.     puPrint = *huPrint;
  364.     poPrint = *hoPrint;
  365.  
  366.     // save away fields within the universal record that we'll be stomping over
  367.     // as we convert
  368.     options         = puPrint->options;
  369.     qualityMode     = puPrint->qualityMode;
  370.     actualCopies    = puPrint->actualCopies;
  371.     
  372.     poPrint->iPrVersion            = 4;        // used to be 3, but this is
  373.                                             // a new driver.  We support versions
  374.                                             // 3 and 4
  375.     poPrint->prInfo.iDev        = 0;        // always zero for the ImageWriter
  376.     
  377.     // skip remaining fields in prInfo because they are unchanged
  378.     
  379.     // determine the wDev
  380.     {
  381.     short    wDev;
  382.     
  383.     // this is the wDev value for the ImageWriter
  384.     wDev = 0x0100;
  385.     
  386.     if (puPrint->orientation == gxPortraitOrientation)
  387.         wDev |= kPortrait;
  388.     else
  389.         {
  390.         // for landscape, disable draft and force tall adjusted
  391.         if (qualityMode == gxDraftQuality)
  392.             qualityMode = gxFasterQuality;
  393.             
  394.         options |= gxPreciseBitmap;
  395.         }
  396.     
  397.     // user options
  398.     if (options & gxPreciseBitmap)
  399.         wDev |= kTallAdjusted;
  400.     if (options & gxUserFlag0)
  401.         {
  402.         wDev |= k50Percent;
  403.         qualityMode = gxFasterQuality;
  404.         }
  405.  
  406.     if (options & gxBiggerPages)
  407.         wDev |= kNoGaps;
  408.         
  409.     // if the application's resolution isn't 72 - then clearly SetRsl must have been called
  410.     // to change it.
  411.     if (poPrint->prInfo.iVRes != 72)
  412.         {
  413.         wDev |= kSetResCalled;
  414.         qualityMode = gxBestQuality;
  415.         }
  416.         
  417.     if (qualityMode == gxBestQuality)
  418.         wDev |= kBest;
  419.         
  420.         
  421.     // and finally, save away that short value we worked so hard to determine
  422.     poPrint->prStl.wDev = wDev;
  423.     }
  424.  
  425.     // other fields in prStl remain the same
  426.     
  427.     poPrint->prStl.bPort     = 0;
  428.     poPrint->prStl.feed     = 1 - (puPrint->feed);
  429.     poPrint->prInfoPT.iDev     = (qualityMode == gxBestQuality) ? -768 : 0;
  430.  
  431.     // other fields in prInfoPT remain the same
  432.     {
  433.     Rect    rPage = poPrint->prInfoPT.rPage;
  434.     
  435.     // calculate some fields we don't use - in case someone really wants to look at
  436.     // them for some reason
  437.     poPrint->prXInfo.iRowBytes    = rPage.right >> 3;
  438.     poPrint->prXInfo.iBandV        = 32;
  439.     poPrint->prXInfo.iBandH        = poPrint->prXInfo.iRowBytes << 3;
  440.     poPrint->prXInfo.iDevBytes    = poPrint->prXInfo.iRowBytes * 
  441.                                     poPrint->prXInfo.iBandV + 
  442.                                     poPrint->prXInfo.iBandH;
  443.     poPrint->prXInfo.iBands        = (rPage.bottom+(poPrint->prXInfo.iBandV-1)) / poPrint->prXInfo.iBandV;
  444.     poPrint->prXInfo.bPatScale     = (qualityMode == gxBestQuality) ? -2 : 0;
  445.     poPrint->prXInfo.bUlThick     = 1;
  446.     poPrint->prXInfo.bUlOffset     = 1;
  447.     poPrint->prXInfo.bUlShadow     = 1;
  448.     poPrint->prXInfo.scan        = (poPrint->prStl.wDev & kPortrait) ? 0 : 2;
  449.     poPrint->prXInfo.bXInfoX    = 0;
  450.     }
  451.     
  452.     // other fields in prJob remain the same
  453.     poPrint->prJob.iCopies        = actualCopies;
  454.     poPrint->prJob.bJDocLoop    = (qualityMode == gxDraftQuality) ? 0 : 1;
  455.     
  456.     // this routine is so studly, there can be no errors
  457.     return(noErr);    
  458.     
  459. } // SD_ConvertPrintRecordFrom
  460.  
  461.  
  462. //<FF>
  463. /* ----------------------------------------------------------------------------    */
  464. OSErr SD_PrintRecordToJob(THPrint hPrint, gxJob theJob)
  465. /*
  466.     We convert the "tall adjusted" setting into the correct rendering option for
  467.     the job collection.
  468. */
  469. {
  470.     OSErr    anErr;
  471.     Handle     jobQualitySettingsHdl;    
  472.     
  473.     anErr = Forward_GXPrintRecordToJob(hPrint, theJob);
  474.     if (anErr == noErr)
  475.         {
  476.         long imagewriterOptions = kSuperRes;
  477.         
  478.         if ((**hPrint).prStl.wDev & kSetResCalled)
  479.             {
  480.             Collection            jobCollection = GXGetJobCollection(GXGetJob());
  481.             gxQualityInfo        *qualitySettings;
  482.     
  483.  
  484.             // get old info and replace it with final quality
  485.  
  486.  
  487.             jobQualitySettingsHdl = NewHandle(0);
  488.             anErr = MemError();
  489.             nrequire(anErr, FailedNewHandle);
  490.  
  491.             anErr = GetCollectionItemHdl (     jobCollection,
  492.                                                 gxQualityTag,
  493.                                                  gxPrintingTagID,
  494.                                                jobQualitySettingsHdl );
  495.  
  496.             if (anErr == collectionItemNotFoundErr) 
  497.                 {
  498.                 Str255            bestString, roughString;
  499.                 Size            count1, count2;
  500.                 Ptr                p;
  501.                 short            curResFile = CurResFile();
  502.                 
  503.                 UseResFile(GXGetMessageHandlerResFile());
  504.                 GetIndString( bestString, kOldQualityID, kBestString);
  505.                 GetIndString( roughString, kOldQualityID, kRoughString);
  506.                 UseResFile(curResFile);
  507.  
  508.                 SetHandleSize(jobQualitySettingsHdl,(sizeof(gxQualityInfo) + bestString[0] + roughString[0] + 2 ));
  509.                 anErr = MemError();
  510.                 nrequire( anErr, FailedSetHandleSize );
  511.                         
  512.                 qualitySettings = *((gxQualityInfo **) jobQualitySettingsHdl);
  513.                 
  514.                 qualitySettings->disableQuality = false;
  515.                 qualitySettings->defaultQuality = 1;
  516.                 qualitySettings->currentQuality = 1;
  517.                 qualitySettings->qualityCount = 2;
  518.         
  519.                 count1 = bestString[0]+1;
  520.                 p = qualitySettings->qualityNames;
  521.                 BlockMove( bestString, p, count1 );
  522.         
  523.                 count2 = roughString[0]+1;
  524.                 p += count1;
  525.                 BlockMove( roughString, p, count2 );
  526.         
  527.                 }
  528.             else
  529.                 qualitySettings = *((gxQualityInfo **) jobQualitySettingsHdl);
  530.  
  531.             (qualitySettings->currentQuality = qualitySettings->qualityCount-1);
  532.  
  533.             anErr = AddCollectionItemHdl (     jobCollection,
  534.                                             gxQualityTag,
  535.                                             gxPrintingTagID,
  536.                                             jobQualitySettingsHdl );
  537.                                                  
  538.             if (anErr == noErr)
  539.                 (void) SetCollectionItemInfo(jobCollection, gxQualityTag, gxPrintingTagID, 0x0000FFFF, gxVolatileOutputDriverCategory);
  540.                 
  541.             DisposHandle(jobQualitySettingsHdl);
  542.             }
  543.  
  544.         if ((**hPrint).prStl.wDev & kTallAdjusted)
  545.             imagewriterOptions = 0;
  546.             
  547.         if (anErr == noErr)
  548.             anErr = AddCollectionItem(GXGetJobCollection(theJob), 
  549.                         DriverCreator,
  550.                         0,
  551.                         sizeof(imagewriterOptions),
  552.                         &imagewriterOptions);
  553.         }
  554.  
  555. FailedNewHandle:        
  556.     return(anErr);
  557.  
  558. FailedSetHandleSize:
  559.     DisposHandle(jobQualitySettingsHdl);
  560.     return(anErr);
  561.     
  562. } // SD_PrintRecordToJob
  563.  
  564. //<FF>
  565. /* ----------------------------------------------------------------------------    */
  566. OSErr SD_PrValidate(    THPrint hPrint,                 // old style print record
  567.                         Boolean *wasChanged)            // was the print record changed?
  568. /*
  569.     This call validates the current print record.  It's fairly simplistic (as were
  570.     all of the old drivers) - the wDev or versions don't match the current, we call
  571.     PrintDefault.  Otherwise, we call UpdatePrintRecord - to allow the driver to sanity
  572.     check any internal fields.
  573.     
  574. */
  575. {
  576.     unsigned short    wDev;                        // note: if this were signed, the shift below would fail                    
  577.     Boolean            recordIsInvalid = true;            
  578.     OSErr            anErr = noErr;
  579.     
  580.     // check the wDev.  The upper byte must be equal to our idea of the wDev
  581.         
  582.     wDev =  (**hPrint).prStl.wDev;    
  583.     wDev >>= 8;                                // get just the device ID
  584.  
  585.     // If the device id is equal, then check the version number of the print record.
  586.     //    Only if that is also equal to the current version, will we return false (valid).
  587.         
  588.     if (     (wDev == 1) 
  589.         &&
  590.             (
  591.             ( ((**hPrint).iPrVersion) == 3 ) ||
  592.             ( ((**hPrint).iPrVersion) == 4 ) 
  593.             )
  594.         )
  595.         recordIsInvalid = false;
  596.             
  597.  
  598.     // If the the print record is not valid, then return the default print record.
  599.     // Otherwise, update the print record, based on the application's calls
  600.     // to PrGeneral.
  601.         
  602.     if (recordIsInvalid)
  603.         PrintDefault(hPrint);
  604.     else
  605.         anErr = UpdatePrintRecord(hPrint);
  606.         
  607.     *wasChanged = recordIsInvalid;
  608.     
  609.     return (anErr);
  610.     
  611. } // SD_PrValidate
  612.  
  613. //<FF>
  614. /* ----------------------------------------------------------------------------    */
  615. OSErr SD_PrJobInit(THPrint hPrint, TPPrDlg * pDlg)
  616. /*
  617.     This routine is called to initialize the job dialog.  We take the default
  618.     behavior - and then disable some of the items based on settings the user
  619.     has made:
  620.         - 50% disables all items
  621.         - apps that call SetRsl disable all items
  622.         - landscape disables draft mode
  623. */
  624. {
  625.     OSErr    anErr;
  626.     
  627.     anErr = Forward_GXPrJobInit(hPrint, pDlg);
  628.     if (anErr == noErr)
  629.         {
  630.         Boolean    disableDraft     = false;
  631.         Boolean    disableAll         = false;
  632.         short    wDev             = (**hPrint).prStl.wDev;
  633.         short    idx;
  634.         Rect    box;
  635.         Handle    item;
  636.         short    type;
  637.         
  638.         if (wDev & k50Percent)
  639.             disableAll = true;
  640.             
  641.         if (wDev & kSetResCalled)
  642.             disableAll = true;
  643.             
  644.         if (!(wDev & kPortrait))
  645.             disableDraft = true;
  646.         
  647.         // disable any controls we need to
  648.         for (idx = 6; idx <= 8; ++idx)
  649.             {
  650.             GetDItem((DialogPtr) *pDlg, idx, &type, &item, &box);
  651.             
  652.             if ( (disableAll) || ((disableDraft) && (idx == 8) ) )
  653.                 HiliteControl((ControlHandle) item, 255);
  654.             
  655.             }
  656.         }
  657.  
  658.     return(anErr);
  659.     
  660. } // SD_PrJobInit